/*
* 舆情环比分析
* */

$(function () {

    let myChart = echarts.init(document.getElementById("trendChart"));
    let option = {
        legend: { // 图例组件
            textStyle:{
                color:'#b0c2f9'
            },
            bottom:0
        },
        tooltip: {

        },
        series : [
            {
                type: 'pie',
                color: ['#e6b600','#7760f6','#3FEEF6'],
                radius: '55%',
                data:[
                    { value:0, name:'东营市人民医院' },
                    { value:0, name:'胜利油田中心医院' },
                    { value:0, name:'其他医院' },
                ],
                itemStyle:  {
                    normal:{
                        label:{
                            show: true,
                            formatter: '{b} \n\n {c}({d}%)',
                        },
                        labelLine :{show:true}
                    }
                },
                labelLine: {
                    normal: {
                        length: 5,
                        length2:5,
                    }

                },
            },

        ],

    }

    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }

    $.ajax({
        url: "/hospital/total/analysis",
        dataType: "json"
    }).done(function(data) {
        myChart.setOption({
            series: [{
                data: data.result
            }]
        });
    }).fail(function(jqXHR) {
        console.log("Ajax Fail: ", jqXHR.status, jqXHR.statusText);
    });

    //浏览器窗口大小变化时，重置报表大小
    $(window).resize(function() {
        myChart.resize();
    });

});